import React, { Component, createRef } from 'react';
import { connect } from "umi"
import { DownOutlined, ExclamationCircleOutlined, FormOutlined, PlusOutlined, DeleteOutlined, CopyOutlined, UploadOutlined, } from '@ant-design/icons';
import { Button, Space, Dropdown, Menu, message, Modal, Popover, Switch, Radio, Tooltip, Upload, Row, Col, Input } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
// import MotionLayout from '@/layouts/MotionLayout';
import moment from "moment";
import ImageBox from '@/components/ImageBox';
import { sfLogList, sfLogListByQuery, sfLogAdd, sfLogEdit, sfLogDel, sfLogEditMulti } from "@/services/sfLogService";

import UpdateForm from './components/UpdateForm';
import CreateForm from './components/CreateForm';

import SelectBox from "@/components/SelectBox"
import { SaveTable } from "@/utils/excelHelp"

import path from "path"
const actionRef = createRef();
import styles from "./index.less"
import copy from 'copy-to-clipboard';

class Page extends Component {
  constructor(props) {
    super(props)
    this.state = {
      SwitchisDeal: false,
      SwitchisSend: false,
      createModalVisible: false,
      updateModalVisible: false,
      selectRow: {},
      params: {},
      uploading: false,
      userName: "",
      detail: "",
      userGroup: "",
      screenshot: "",
      AreaValue: "",
      isdetailMode: false,
    }

  }

  async handleDeal({ fields, serviceMethod, type = "操作" }) {
    const hide = message.loading("正在" + type);
    try {
      const res = await serviceMethod(fields);
      hide();
      if (!res.success) {
        message.error(type + "失败，" + res.result);
        return false;
      }
      message.success(type + "成功");
      return true;
    } catch (error) {
      hide();
      message.error(type + "异常，" + error);
      return false;
    }
  }
  async getDataSource(params) {
    const { result, success } = await sfLogListByQuery({
      ...params,
      ...(params["createTime"] == undefined ? {} : { ["createTime"]: params["createTime"].map(item => moment(item).format("YYYY-MM-DD HH:mm:ss")).join(",") }),
      ...(params["dealTime"] == undefined ? {} : { ["dealTime"]: params["dealTime"].map(item => moment(item).format("YYYY-MM-DD HH:mm:ss")).join(",") }),
      ...(params["updateTime"] == undefined ? {} : { ["updateTime"]: params["updateTime"].map(item => moment(item).format("YYYY-MM-DD HH:mm:ss")).join(",") }),
      page: params.current,
      limit: params.pageSize,
    })
    if (!success) {
      return {
        data: [],
        page: 1,
        success: false,
        total: 0,
      };
    }
    this.setState({
      params,
    })
    return {
      data: result.arr,
      page: 1,
      success: true,
      total: result.count,
    };
  }
  createColumns() {
    return [
      {
        title: '信息来源',
        dataIndex: 'userGroup',
        valueType: "text",
        hideInSearch: false,
        hideInTable: false,
        hideInForm: false,
        rules: [{
          required: true,
        }],
        valueEnum: {

          "司法矫正管理群（黄石大冶）": {
            text: '司法矫正管理群（黄石大冶）',
          },

          "监利司法E通工作群": {
            text: '监利司法E通工作群',
          },

          "宜昌司法E通": {
            text: '宜昌司法E通',
          },

          "湖北电信司法E通": {
            text: '湖北电信司法E通',
          },
        },
        width: 120,
      },
      {
        title: '客户名称',
        dataIndex: 'userName',
        valueType: "text",
        render: (_, row) => (<span onDoubleClick={(e) => {
          e.stopPropagation();
          copy(
            row["userName"]
          );
          message.success('复制成功');
        }}>{row["userName"]}</span>),
        hideInSearch: false,
        hideInTable: false,
        hideInForm: false,
        rules: [{
          required: true,
        }],
        width: 120,
        order: 10,
      },
      {
        title: '截图',
        dataIndex: 'screenshot',
        valueType: "text",
        hideInSearch: true,
        hideInTable: true,
        rules: [{
          required: false,
        }],
        renderFormItem: (item, { defaultRender, ...rest }, form) => {
          return (<ImageBox arr={[]} maxSize={3} action="/api/sfLog/uploadImg" />)
        },
      },
      {
        title: '截图',
        dataIndex: 'screenshot',
        valueType: 'option',
        render: (_, row) => {
          return (
            <div style={{ width: 50, height: 50, overflow: "hidden" }}>
              <img style={{ width: "100%" }} src={row["screenshot"]} alt="" />
            </div>
          )
        }
      },
      {
        title: '详情',
        dataIndex: 'detail',
        valueType: "textarea",
        render: (_, row) => (<span onDoubleClick={(e) => {
          e.stopPropagation();
          copy(
            row["detail"]
          );
          message.success('复制成功');
        }}>{row["detail"]}</span>),
        hideInSearch: false,
        hideInTable: false,
        hideInForm: false,
        rules: [{
          required: false,
        }],
        width: 300,
        formItemProps: {
          rows: 4,
        },
        order: 9,
      },
      {
        title: '回复',
        dataIndex: 'reply',
        valueType: "textarea",
        render: (_, row) => (<span onDoubleClick={(e) => {
          e.stopPropagation();
          copy(
            row["reply"]
          );
          message.success('复制成功');
        }}>{row["reply"]}</span>),
        hideInSearch: false,
        hideInTable: false,
        hideInForm: false,
        rules: [{
          required: false,
        }],
        formItemProps: {
          allowClear: true,
        },
      },

      {
        title: '处理条数',
        dataIndex: 'dealCount',
        valueType: "digit",
        hideInSearch: false,
        hideInTable: !this.state.isdetailMode,
        hideInForm: false,
        rules: [{
          required: false,
        }],
        formItemProps: { precision: 0, max: 999999, maxLength: 6 },

      },



      {
        title: '创建时间',
        dataIndex: 'createTime',
        valueType: "date",
        render: (_, row) => row["createTime"] ? moment(row["createTime"]).format("YYYY-MM-DD HH:mm") : "",
        hideInSearch: true,
        hideInTable: !this.state.isdetailMode,
        hideInForm: true,
        rules: [{
          required: true,
        }],
      },
      {
        title: '创建时间',
        dataIndex: 'createTime',
        valueType: 'dateRange',
        hideInSearch: false,
        hideInTable: true,
        hideInForm: true,
      },

      {
        title: '处理时间',
        dataIndex: 'dealTime',
        valueType: "date",
        render: (_, row) => row["dealTime"] ? moment(row["dealTime"]).format("YYYY-MM-DD") : "",
        hideInSearch: true,
        hideInTable: false,
        hideInForm: false,
        rules: [{
          required: true,
        }],
      },
      {
        title: '处理时间',
        dataIndex: 'dealTime',
        valueType: 'dateRange',
        hideInSearch: false,
        hideInTable: true,
        hideInForm: true,
      },

      {
        title: '更新时间',
        dataIndex: 'updateTime',
        valueType: "date",
        render: (_, row) => row["updateTime"] ? moment(row["updateTime"]).format("YYYY-MM-DD HH:mm") : "",
        hideInSearch: true,
        hideInTable: !this.state.isdetailMode,
        hideInForm: true,
        rules: [{
          required: true,
        }],
      },
      {
        title: '更新时间',
        dataIndex: 'updateTime',
        valueType: 'dateRange',
        hideInSearch: false,
        hideInTable: true,
        hideInForm: true,
      },
      {
        title: '备注',
        dataIndex: 'remark',
        valueType: "textarea",
        hideInSearch: false,
        hideInTable: !this.state.isdetailMode,
        hideInForm: false,
        rules: [{
          required: false,
        }],

      },
      {
        title: '处理人',
        dataIndex: 'dealName',
        valueType: "text",
        hideInSearch: false,
        hideInTable: !this.state.isdetailMode,
        hideInForm: true,
        rules: [{
          required: true,
        }],

      },
      {
        title: '创建人',
        dataIndex: 'createName',
        valueType: "text",
        hideInSearch: false,
        hideInTable: !this.state.isdetailMode,
        hideInForm: true,
        rules: [{
          required: true,
        }],

      },
      {
        title: '是否处理',
        dataIndex: 'isDeal',
        hideInSearch: false,
        hideInTable: true,
        hideInForm: false,
        rules: [{
          required: true,
        }],
        valueEnum: {
          [false]: {
            text: '未处理',
            status: 'Default',
          },
          [true]: {
            text: '已处理',
            status: 'Processing',
          },
        },
      },

      {
        title: '是否处理',
        dataIndex: 'isDeal1',
        valueType: 'option',
        render: (_, row) => {
          return (<Switch disabled={this.state.SwitchisDeal}
            checkedChildren={"已处理"} unCheckedChildren={"未处理"}
            onChange={async (val) => {
              const success = await this.handleDeal({
                type: "操作",
                fields: {
                  ["id"]: row["id"],
                  ["isDeal"]: val,
                },
                serviceMethod: sfLogEdit,
              });
              if (!success) {
                return;
              }
              if (!actionRef.current) {
                return;
              }
              actionRef.current.reload();
            }}
            checked={row["isDeal"]}
          // defaultChecked={_}
          />)
        }
      },
      {
        title: '是否反馈',
        dataIndex: 'isSend',
        hideInSearch: false,
        hideInTable: true,
        hideInForm: false,
        rules: [{
          required: true,
        }],
        valueEnum: {
          [false]: {
            text: '未反馈',
            status: 'Default',
          },
          [true]: {
            text: '已反馈',
            status: 'Processing',
          },
        },
      },

      {
        title: '是否反馈',
        dataIndex: 'isSend1',
        valueType: 'option',
        render: (_, row) => {
          return (<Switch disabled={this.state.SwitchisSend}
            checkedChildren={"已反馈"} unCheckedChildren={"未反馈"}
            onChange={async (val) => {
              const success = await this.handleDeal({
                type: "操作",
                fields: {
                  ["id"]: row["id"],
                  ["isSend"]: val,
                },
                serviceMethod: sfLogEdit,
              });
              if (!success) {
                return;
              }
              if (!actionRef.current) {
                return;
              }
              actionRef.current.reload();
            }}
            checked={row["isSend"]}
          // defaultChecked={_}
          />)
        }
      },



      {
        title: '操作',
        dataIndex: 'option',
        valueType: 'option',
        render: (_, row) => (
          <Space>

            <Tooltip title="复制这条信息">
              <Button
                title="复制"
                onClick={(e) => {
                  e.stopPropagation();
                  Modal.confirm({
                    title: '是否确认复制该条信息?',
                    icon: <ExclamationCircleOutlined />,
                    onOk: async () => {
                      const success = await this.handleDeal({
                        type: "复制",
                        fields: row,
                        serviceMethod: sfLogAdd,
                      });
                      if (!success) {
                        return;
                      }
                      this.setState({
                        createModalVisible: false,
                      })
                      if (!actionRef.current) {
                        return;
                      }
                      actionRef.current.reload();
                    },
                  });

                }}
                size="small" type="default" icon={<CopyOutlined />}></Button>
            </Tooltip>


            <Tooltip title="编辑">
              <Button
                onClick={async (e) => {
                  e.stopPropagation();
                  const selectRow = {
                    ...row,
                    ...(row["dealCount"] == undefined ? {} : { ["dealCount"]: row["dealCount"].toString() }),
                    ...(row["isDeal"] == undefined ? {} : { ["isDeal"]: row["isDeal"].toString() }),
                    ...(row["isSend"] == undefined ? {} : { ["isSend"]: row["isSend"].toString() }),
                    ...(row["createTime"] == undefined ? {} : { ["createTime"]: moment(row["createTime"]) }),
                    ...(row["dealTime"] == undefined ? {} : { ["dealTime"]: moment(row["dealTime"]) }),
                    ...(row["updateTime"] == undefined ? {} : { ["updateTime"]: moment(row["updateTime"]) }),
                  }
                  this.setState({
                    updateModalVisible: true,
                    selectRow,
                  })
                }}
                size="small" type="primary" icon={<FormOutlined />} ></Button>
            </Tooltip>


            <Tooltip title="删除">
              <Button
                style={{ marginRight: 5 }}
                onClick={(e) => {
                  e.stopPropagation();
                  Modal.confirm({
                    title: '是否确认删除?',
                    icon: <ExclamationCircleOutlined />,
                    onOk: async () => {
                      const idList = {
                        id: [
                          row["id"]
                        ]
                      };
                      const success = await this.handleDeal({
                        type: "删除",
                        fields: idList,
                        serviceMethod: sfLogDel
                      });
                      if (!success) {
                        return;
                      }
                      if (!actionRef.current) {
                        return;
                      }
                      actionRef.current.reload();
                    },
                  });
                }}
                size="small" type="primary" icon={<DeleteOutlined />}></Button>
            </Tooltip>


          </Space>
        ),
      },


    ];
  }
  getArr() {
    const columns = this.createColumns().filter(item => item.valueType != "option");
    const ARR = [...new Set(columns.map(item => item.dataIndex))].map(item => {
      const obj = columns.find(sitem => sitem.dataIndex == item);
      return {
        label: obj.title,
        value: obj.dataIndex,
      }
    })
    return ARR;
  }
  componentDidMount() {
    const that = this;
    var body = document.getElementsByTagName('body')[0];
    body.addEventListener('paste', function (e) {
      var clipboard = e.clipboardData;
      var type = clipboard.items[0].type;
      if (type.match(/image/)) {
        var blob = clipboard.items[0].getAsFile();
        var file = new FileReader();
        file.addEventListener('loadend', function (e) {
          if (that.state.createModalVisible) {
            that.setState({
              screenshot: e.target.result
            })
          }
        });
        file.readAsDataURL(blob);
      } else {
        //剪切板不是图片
        // console.log("not an image\ntype: " + type)
      }
    });
  }
  onCancel() {
    this.setState({
      createModalVisible: false,
      userName: "",
      detail: "",
      userGroup: "",
      screenshot: "",
      AreaValue: "",
    })
  }
  render() {

    const importProps = {
      showUploadList: false,
      name: 'file',
      action: '/api/sfLog/importExcel',
      headers: { auth: localStorage.getItem("authInfo") },
      data: {
        jsonStr: JSON.stringify(this.getArr()),
      },
      onChange: (info) => {
        if (info.file.status === 'uploading') {
          this.setState({
            uploading: true,
          });
          return;
        }
        if (info.file.status === 'done') {
          if (info.file.response.success) {
            message.success(info.file.name + " 导入成功！");
            if (!actionRef.current) {
              return;
            }
            actionRef.current.reload();
          }
          else {
            message.error("执行出错！" + info.file.response.result);
          }
          this.setState({
            uploading: false,
          });
        } else if (info.file.status === 'error') {
          this.setState({
            uploading: false,
          });
          message.error(info.file.name + " 上传文件时发生错误！");
        }
      },
      beforeUpload(file) {
        const maxSize = 10;
        const fileEx = path.extname(file.name).toLowerCase();
        if (!(fileEx == ".xls" || fileEx == ".xlsx")) {
          message.error('仅仅支持 Excel 文件! 后缀名为：.xls .xlsx');
          return false;
        }
        const isLt2M = file.size / 1024 / 1024 < maxSize;
        if (!isLt2M) {
          message.error("图片必须小于 " + maxSize + "MB!");
        }
        return isLt2M;
      },
      accept: ".xls,.xlsx",
    };
    return (
      <PageHeaderWrapper>
        {/* <MotionLayout> */}
          <ProTable
            actionRef={actionRef}
            headerTitle={""}
            rowKey="id"
            params={{}}
            request={async (params) => this.getDataSource(params)}
            columns={this.createColumns()}
            rowSelection={{}}
            pagination={{
              pageSize: 10,
            }}
            search={true}
            toolBarRender={(action, { selectedRowKeys, selectedRows }) => {
              return ([
                <Switch
                  size="default"
                  checkedChildren="详情模式" unCheckedChildren="工作模式"
                  onChange={(isEnable) => {
                    if (isEnable) {
                      this.props.dispatch({
                        type: 'global/changeLayoutCollapsed',
                        payload: true,
                      });
                    }
                    else {
                      this.props.dispatch({
                        type: 'global/changeLayoutCollapsed',
                        payload: false,
                      });
                    }
                    this.setState({
                      isdetailMode: isEnable,
                    })
                  }}
                  checked={this.state.isdetailMode}
                />,
                <Popover
                  content={
                    <div style={{ padding: "12px 10px" }}>
                      <div style={{ padding: "10px 30px" }}>请以 “导出” 的文件为模板导入</div>
                      <div style={{ textAlign: "right", marginTop: 15 }}>
                        <Upload  {...importProps}>
                          <Button type="primary" loading={this.state.uploading} icon={<UploadOutlined />}>上传EXCEL文件</Button>
                        </Upload>
                      </div>
                    </div>
                  }
                  title="导入数据"
                  trigger="click">
                  <Button type="dashed">导入</Button>
                </Popover>,


                <Popover
                  content={
                    <SelectBox
                      Submit={async (arr) => {
                        const res = await sfLogListByQuery({
                          ...this.state.params,
                          ...(this.state.params["createTime"] == undefined ? {} : { ["createTime"]: this.state.params["createTime"].map(item => moment(item).format("YYYY-MM-DD HH:mm:ss")).join(",") }),
                          ...(this.state.params["dealTime"] == undefined ? {} : { ["dealTime"]: this.state.params["dealTime"].map(item => moment(item).format("YYYY-MM-DD HH:mm:ss")).join(",") }),
                          ...(this.state.params["updateTime"] == undefined ? {} : { ["updateTime"]: this.state.params["updateTime"].map(item => moment(item).format("YYYY-MM-DD HH:mm:ss")).join(",") }),
                          page: 1,
                          limit: 10000,
                        })
                        if (!res.success) {
                          message.error("操作失败，" + res.result);
                          return;
                        }
                        let mapping = {};
                        arr.forEach(ele => {
                          mapping[ele.value] = ele.label;
                        })
                        SaveTable({
                          arr: res.result.arr,
                          mapping,
                          isOrder: false,
                        })
                      }}
                      arr={this.getArr()} />}
                  title="选择要导出的字段"
                  trigger="click">
                  <Button type="dashed">导出</Button>
                </Popover>,

                <Button type="primary" onClick={() => {
                  const selectRow = {}
                  this.setState({
                    createModalVisible: true,
                    selectRow,
                  })
                }}>
                  <PlusOutlined /> 新建
                          </Button>,

                selectedRowKeys && selectedRowKeys.length > 0 && (
                  <Dropdown
                    overlay={
                      <Menu
                        onClick={async e => {
                          const obj = {
                            "remove": "删除",
                            "isDeal": "标记已处理",
                            "isReply": "标记已反馈",
                            "isNotDeal": "标记未处理",
                            "isNotReply": "标记未反馈",
                          }
                          Modal.confirm({
                            title: `是否确认${obj[e.key]}?`,
                            icon: <ExclamationCircleOutlined />,
                            onOk: async () => {
                              let success = false;
                              if (e.key === 'remove') {
                                success = await this.handleDeal({
                                  type: "删除",
                                  fields: {
                                    id: selectedRowKeys
                                  },
                                  serviceMethod: sfLogDel
                                });
                              }

                              if (e.key === 'isDeal') {
                                success = await this.handleDeal({
                                  type: "批量标记为已处理",
                                  fields: {
                                    idList: selectedRowKeys,
                                    isBool: true,
                                    boolType: "isDeal"
                                  },
                                  serviceMethod: sfLogEditMulti
                                });
                              }
                              if (e.key === 'isReply') {
                                success = await this.handleDeal({
                                  type: "批量标记为已反馈",
                                  fields: {
                                    idList: selectedRowKeys,
                                    isBool: true,
                                    boolType: "isReply"
                                  },
                                  serviceMethod: sfLogEditMulti
                                });
                              }
                              if (e.key === 'isNotDeal') {
                                success = await this.handleDeal({
                                  type: "批量标记为已反馈",
                                  fields: {
                                    idList: selectedRowKeys,
                                    isBool: false,
                                    boolType: "isDeal"
                                  },
                                  serviceMethod: sfLogEditMulti
                                });
                              }
                              if (e.key === 'isNotReply') {
                                success = await this.handleDeal({
                                  type: "批量标记为已反馈",
                                  fields: {
                                    idList: selectedRowKeys,
                                    isBool: false,
                                    boolType: "isReply"
                                  },
                                  serviceMethod: sfLogEditMulti
                                });
                              }
                              if (!success) {
                                return;
                              }
                              if (!actionRef.current) {
                                return;
                              }
                              actionRef.current.reload();

                            },
                          });



                        }}
                        selectedKeys={[]}
                      >
                        <Menu.Item key="remove">批量删除</Menu.Item>
                        <Menu.SubMenu title="批量标记完成">
                          <Menu.Item key="isDeal">批量标记为已处理</Menu.Item>
                          <Menu.Item key="isReply">批量标记为已反馈</Menu.Item>
                        </Menu.SubMenu>
                        <Menu.SubMenu title="批量标记未完成">
                          <Menu.Item key="isNotDeal">批量标记为未处理</Menu.Item>
                          <Menu.Item key="isNotReply">批量标记为未反馈</Menu.Item>
                        </Menu.SubMenu>

                      </Menu>
                    }
                  >
                    <Button>
                      批量操作 <DownOutlined />
                    </Button>
                  </Dropdown>
                ),
              ]);
            }}
          />
        {/* </MotionLayout> */}
        {/* 添加 */}
        <Modal
          id="addModal"
          title="添加"
          destroyOnClose={true}
          maskClosable={false}
          footer={<>
            <Button onClick={() => {
              this.onCancel();
            }}>取消</Button>
            <Button type="primary" onClick={async () => {
              const fields = {
                userName: this.state.userName,
                detail: this.state.detail,
                userGroup: this.state.userGroup,
                screenshot: this.state.screenshot,
              }
              console.log(fields)
              if (this.state.userName == "" || this.state.userGroup == "") {
                message.warning("用户名称或信息来源未填写")
                return;
              }
              if (this.state.detail == "" && this.state.screenshot == "") {
                message.warning("详情或者截图必须二选一填写")
                return;
              }



              const success = await this.handleDeal({
                type: "添加",
                fields,
                serviceMethod: sfLogAdd,
              });
              if (!success) {
                return;
              }
              this.onCancel();
              if (!actionRef.current) {
                return;
              }
              actionRef.current.reload();
            }}>
              完成
        </Button>
          </>}
          onCancel={() => {
            this.onCancel();
          }}
          visible={this.state.createModalVisible}
        >
          <Row>
            <Col span={24}>
              <Input.TextArea
                value={this.state.AreaValue}
                onChange={({ target: { value } }) => {
                  // console.log(value);
                  const vs = value.split(`\n`);
                  const userName = vs[0].includes("(") ? vs[0].split("(")[0] : vs[0].split("<")[0];
                  const obj = {
                    userName: vs[0].includes("(") || vs[0].includes("<") ? userName : "",
                    detail: value.includes("\n") ? vs.filter((item, index) => index > 0).join("\n") : value,
                  };
                  this.setState({
                    ...obj,
                    AreaValue: value,
                  })
                }}
                placeholder="请复制录入内容"
                rows={7}
              />
            </Col>
            <Col span={24} style={{ marginTop: 10 }}>
              用户名称：
            </Col>
            <Col span={24}>
              <Input value={this.state.userName} onChange={({ target: { value } }) => this.setState({ userName: value })} />
            </Col>
            <Col span={24} style={{ marginTop: 10 }}>
              详情：
            </Col>
            <Col span={24}>
              <Input.TextArea rows={3} value={this.state.detail} onChange={({ target: { value } }) => this.setState({ detail: value })} />
            </Col>
            <Col span={24} style={{ marginTop: 10 }}>
              截图：
            </Col>
            <Col span={24}>
              <div style={{ width: 300 }}>
                <img src={this.state.screenshot} alt="" style={{ width: "100%" }} />
              </div>
            </Col>
            <Col span={24} style={{ marginTop: 10 }}>
              信息来源：
            </Col>
            <Col span={24}>
              <Radio.Group
                className={styles.RadioGroup}
                options={[
                  { label: '司法矫正管理群（黄石大冶）', value: '司法矫正管理群（黄石大冶）' },
                  { label: '监利司法E通工作群', value: '监利司法E通工作群' },
                  { label: '宜昌司法E通', value: '宜昌司法E通' },
                  { label: '湖北电信司法E通', value: '湖北电信司法E通' },
                ]}
                onChange={(e) => {
                  this.setState({
                    userGroup: e.target.value
                  })
                }}
                value={this.state.userGroup}
                optionType="button"
              />
            </Col>
          </Row>
        </Modal>


        <UpdateForm
          onCancel={() => this.setState({ updateModalVisible: false })}
          updateModalVisible={this.state.updateModalVisible}
        >
          <ProTable
            onSubmit={async fieldsValues => {
              const fields = {
                ...fieldsValues,
                ...(fieldsValues["dealCount"] == undefined ? {} : { ["dealCount"]: Number(fieldsValues["dealCount"]) }),
                ...(fieldsValues["isDeal"] == undefined ? {} : { ["isDeal"]: fieldsValues["isDeal"] == "true" }),
                ...(fieldsValues["isSend"] == undefined ? {} : { ["isSend"]: fieldsValues["isSend"] == "true" }),
                ["id"]: this.state.selectRow["id"],
              }
              const success = await this.handleDeal({
                type: "更新",
                fields,
                serviceMethod: sfLogEdit,
              });
              if (!success) {
                return;
              }
              this.setState({
                updateModalVisible: false,
              })
              if (!actionRef.current) {
                return;
              }
              actionRef.current.reload();
            }}
            rowKey="id"
            type="form"
            form={{
              initialValues: {
                ...this.state.selectRow,
              }
            }}
            columns={this.createColumns()}
          />
        </UpdateForm>

      </PageHeaderWrapper>
    )
  }
}
export default connect()(Page)    